// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-6-28

#ifndef __ROOMLIST_H_CLIENT_MAIN__
#define __ROOMLIST_H_CLIENT_MAIN__

#pragma once

#include <common\ui\listview.h>

class CJoyRoomList;

//##ModelId=44C4B5DF0128
class CJoyRoomItem : public CJoyListViewItem
{
protected:
	//##ModelId=44C4B5DF0138
    void DrawTroop(Graphics& graph);

	//##ModelId=44C4B5DF013A
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44C4B5DF0149
    virtual void CM_Mouse(MouseMessage msg, const CPoint& pt);
public:
	//##ModelId=44C4B5DF0159
    CStringW m_roomName;
	//##ModelId=44C4B5DF0167
    CString m_serverIP;
    //CStringW m_network;
	//##ModelId=44C4B5DF0168
    UINT    m_roomId;
	//##ModelId=44C4B5DF0169
    UINT    m_userLevel;
	//##ModelId=44C4B5DF016A
    UINT    m_userLevelMax;
	//##ModelId=44C4B5DF0177
    UINT    m_userNow;
	//##ModelId=44C4B5DF0178
    UINT    m_userMax;
	//##ModelId=44C4B5DF0179
    UINT    m_serverPort;
	//##ModelId=44C4B5DF0186
    UINT    m_gameId;
	//##ModelId=44C4B5DF0187
    int     m_network;
	//##ModelId=44C4B5DF0188
    int     m_prize;
	//##ModelId=44C4B5DF0189
    int     m_credit;
	//##ModelId=44C4B5DF0196
    bool    m_recordScore;

    // troop property.
	//##ModelId=44C4B5DF0197
    UINT    m_troopId;
	//##ModelId=44C4B5DF0199
    CStringW m_troopName;
	//##ModelId=44C4B5DF01A5
    bool    m_expand;
public:
	//##ModelId=44C4B5DF01A6
    CJoyRoomItem(void);
	//##ModelId=44C4B5DF01B5
    virtual ~CJoyRoomItem(void);

	//##ModelId=44C4B5DF01C5
    CJoyRoomList* GetRoomList() const
    {
        return (CJoyRoomList*)m_listView;
    }
};

//##ModelId=44C4B5DF01C7
class CJoyRoomField : public CJoyListViewField
{
public:
	//##ModelId=44C4B5DF01D5
    virtual void CM_Draw(Graphics& graph);
	//##ModelId=44C4B5DF01D8
    virtual int CM_CompareItem(CJoyListViewItem*, CJoyListViewItem*);
};

namespace JoyRoomListFields
{
class RoomNameField;
class UserLevelField;
class UserNowField;
class NetworkField;
};

//##ModelId=44C4B5DF0203
class CJoyRoomList :
    public CJoyListView
{
	DECLARE_DYNAMIC(CJoyRoomList)
protected:
	//##ModelId=44C4B5DF0205
    virtual void CM_LoadSkin(CJoyXmlElement* pSkinElem);
public:
	//##ModelId=44C4B5DF0215
    Color   m_backColor;
	//##ModelId=44C4B5DF021A
    Color   m_lightFrameColor;
	//##ModelId=44C4B5DF0223
    Color   m_darkFrameColor;
	//##ModelId=44C4B5DF0228
    Color   m_selTextColor;
	//##ModelId=44C4B5DF022D
    Color   m_selLightFrameColor;
	//##ModelId=44C4B5DF0233
    Color   m_selDarkFrameColor;
	//##ModelId=44C4B5DF0238
    Color   m_selBackColor;

	//##ModelId=44C4B5DF0243
    CJoyImagePtr    m_roomIcon;
	//##ModelId=44C4B5DF0248
    CJoyImagePtr    m_net0;
	//##ModelId=44C4B5DF024D
    CJoyImagePtr    m_net1;
	//##ModelId=44C4B5DF0252
    CJoyImagePtr    m_net2;
	//##ModelId=44C4B5DF0257
    CJoyImagePtr    m_net3;
	//##ModelId=44C4B5DF0262
    CJoyImagePtr    m_netUnknown;

	//##ModelId=44C4B5DF0266
    CString m_channelName;
	//##ModelId=44C4B5DF0267
    CString m_regionName;
	//##ModelId=44C4B5DF0271
    CString m_lobbyName;
	//##ModelId=44C4B5DF0272
    UINT    m_lobbyId;

    // fields.
	//##ModelId=44C4B5DF0281
    JoyRoomListFields::RoomNameField*  m_roomNameField;
	//##ModelId=44C4B5DF0291
    JoyRoomListFields::UserLevelField* m_userLevelField;
	//##ModelId=44C4B5DF0296
    JoyRoomListFields::UserNowField*   m_userNowField;
	//##ModelId=44C4B5DF02A0
    JoyRoomListFields::NetworkField*   m_networkField;
public:
	//##ModelId=44C4B5DF02A4
    CJoyRoomList(void);
	//##ModelId=44C4B5DF02A6
    virtual ~CJoyRoomList(void);

	//##ModelId=44C4B5DF02AF
    void UpdateItem(const CString& strIP, int nDelay);
	//##ModelId=44C4B5DF02BF
    void ToggleItem(CJoyRoomItem* item);
	//##ModelId=44C4B5DF02C1
    CJoyImagePtr& GetNetIcon(int network);

	CJoyRoomItem* GetRoomItem(UINT m_roomId);

	//##ModelId=44C4B5DF02CF
    virtual void SortItem(CJoyListViewField* pField, JoyListViewSortType sortType);
public:
    DECLARE_MESSAGE_MAP()
	//##ModelId=44C4B5DF02DF
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
};

#endif  // __ROOMLIST_H_CLIENT_MAIN__
